package com.shinbada.modules.sys.reference.defaults;

import com.shinbada.modules.sys.mapper.UserMapper;
import com.shinbada.modules.sys.reference.OfficeReferenceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author initcap
 * @date Created in 2021/2/5 17:20.
 */
@Service
public class OfficeReferenceServiceImpl implements OfficeReferenceService {

    private final UserMapper userMapper;

    @Autowired
    public OfficeReferenceServiceImpl(UserMapper userMapper) {
        this.userMapper = userMapper;
    }

    @Override
    public String getName() {
        return "用户信息";
    }

    @Override
    public boolean isReference(String id) {
        return userMapper.countOfficeId(id) > 0;
    }

    @Override
    public void deleteReference(String id) {
        userMapper.deleteUserByOfficeId(id);
    }
}
